package main

import (
	"io"
	"kafka_go/common"
	"kafka_go/consumer"
	"log"
	"os"

	"github.com/sirupsen/logrus"
)

const topic = "system"

func main() {
	initLog()
	cs := consumer.NewConsumer(common.Group, []string{topic}, &consumer.EventHandler{})
	defer cs.Close()
	go cs.Consume() // 异步消费

	select {}
}

func initLog() {
	writer2 := os.Stdout
	writer1, err := os.OpenFile("err.txt", os.O_WRONLY|os.O_CREATE, 0755)
	if err != nil {
		log.Fatalf("create file log.txt failed: %v", err)
	}
	logrus.SetOutput(io.MultiWriter(writer1, writer2))
	logrus.SetLevel(logrus.InfoLevel)
}
